#pragma once
#include <string>
#include <stdlib.h>
#include <Windows.h>

namespace Utility{
	namespace DataConvert{
		std::string itoStr(int value,int radix = 10);
	}

	static void PrintHexDump(void* dest, DWORD length, PBYTE buffer )
	{
		DWORD i,count,index;
		CHAR rgbDigits[]="0123456789abcdef";
		//CHAR rgbLine[100];
		char* rgbLine = (char*)dest;
		char cbLine;

		for(index = 0; length; length -= count, buffer += count, index += count) 
		{
			count = (length > 16) ? 16:length;
			sprintf(rgbLine, "%4.4x  ",index);
			cbLine = 6;

			for(i=0;i<count;i++) 
			{
				rgbLine[cbLine++] = rgbDigits[buffer[i] >> 4];
				rgbLine[cbLine++] = rgbDigits[buffer[i] & 0x0f];
				if(i == 7) rgbLine[cbLine++] = ':';
				else rgbLine[cbLine++] = ' ';
			}
			for(; i < 16; i++) 
			{
				rgbLine[cbLine++] = ' ';
				rgbLine[cbLine++] = ' ';
				rgbLine[cbLine++] = ' ';
			}
			rgbLine[cbLine++] = ' ';

			for(i = 0; i < count; i++) 
			{
				if(buffer[i] < 32 || buffer[i] > 126 || buffer[i] == '%') rgbLine[cbLine++] = '.';
				else rgbLine[cbLine++] = buffer[i];
			}
			rgbLine[cbLine++] = 0;
			//printf("%s\n", rgbLine);
		}
	}


};